﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using System.Data.SqlClient;
using ECONTACT.Controller;

namespace ECONTACT
{
    public partial class frmNhapDiem : Form
    {
        HocKyCtrl m_HocKyCtrl = new HocKyCtrl();
        HocSinhCtrl m_HocSinhCtrl = new HocSinhCtrl();
        LopCtrl m_LopCtrl = new LopCtrl();
        MonHocCtrl m_MonHocCtrl = new MonHocCtrl();
        DiemCtrl m_DiemCtrl = new DiemCtrl();

        public frmNhapDiem()
        {
            InitializeComponent();
        }

        private void frmNhapDiem_Load(object sender, EventArgs e)
        {
            m_HocKyCtrl.HienThiComboBoxTen(cmbMaHocKy);
            m_MonHocCtrl.HienThiComboBoxTen(cmbMaMonHoc);
            m_LopCtrl.HienThiComboBoxTen(cmbMaLop);
            m_HocSinhCtrl.HienThiComboBox(cmbMaHS);
            m_DiemCtrl.HienThi(dGVNhapDiem, cmbMaHS, cmbMaLop, cmbMaMonHoc, cmbMaHocKy, txtDiem, txtNhanXet);
        }

        private void btnThem_Click(object sender, EventArgs e)
        {
            String rs = m_DiemCtrl.LuuDiem(cmbMaHS.SelectedValue.ToString(), cmbMaLop.SelectedValue.ToString(), cmbMaMonHoc.SelectedValue.ToString(), cmbMaHocKy.SelectedValue.ToString(), txtDiem.Text, txtNhanXet.Text);
            if (!rs.Equals("Success"))
            {
                MessageBox.Show(rs);
            }
            m_DiemCtrl.HienThi(dGVNhapDiem, cmbMaHS, cmbMaLop, cmbMaMonHoc, cmbMaHocKy, txtDiem, txtNhanXet);
        }

        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            String rs = m_DiemCtrl.UpdateDiem(cmbMaHS.SelectedValue.ToString(), cmbMaLop.SelectedValue.ToString(), cmbMaMonHoc.SelectedValue.ToString(), cmbMaHocKy.SelectedValue.ToString(), txtDiem.Text, txtNhanXet.Text);
            if (!rs.Equals("Success"))
            {
                MessageBox.Show(rs);
            }
            m_DiemCtrl.HienThi(dGVNhapDiem, cmbMaHS, cmbMaLop, cmbMaMonHoc, cmbMaHocKy, txtDiem, txtNhanXet);
        }
    }
}
